import 'package:flutter/material.dart';
import '../utils/general.dart';

class FFBottomPay extends StatefulWidget {
  final double price;
  FFBottomPay({Key key, this.price = 21.0}):super(key: key);
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return FFBottomPayState();
  }
}

class FFBottomPayState extends State<FFBottomPay> {
  double price = 0.0;
  updatePrice(double newP) {
    setState(() {
      price = newP;
    });
  }
  @override
  Widget build(BuildContext context) {
    double scale = widthScale(context);
    return Container(
      height: 60 * scale,
      child: Row(
        mainAxisAlignment:MainAxisAlignment.spaceBetween,
        children:[
          Padding(
            padding: EdgeInsets.only(left:15 * scale),
            child: Text.rich(
              TextSpan(
                text:'应付合计 ',
                style: TextStyle(fontSize:14 * scale, fontWeight:FontWeight.normal, color: Colors.black87),
                children: [
                  TextSpan(
                    text:'￥${price > 0.0 ? price : widget.price}',
                    style: TextStyle(fontSize:24 * scale, fontWeight:FontWeight.normal, color:Colors.black87),
                  )
                ])
            ),  
          ),
          GestureDetector(
            onTap:(){
              print('结束');
            },
            child:Container(
              width:120 * scale,
              height:60 * scale,
              color:Color.fromRGBO(144, 192, 239, 1.0),
              child:Center(
                child: Text(
                  '去结算',
                  style:TextStyle(fontSize:16 * scale, color:Colors.white),
                ),)
            )
          )
        ]
      ),
    );
  }

}